package com.android.BluethootChess.activity;

import com.android.BluethootChess.activity.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

public class NewGameActivity extends Activity {
    /** Called when the activity is first created. **/
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.new_game);
        
        Button advanceToGame = (Button) findViewById(R.id.advanceToGameButton);
        advanceToGame.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent myIntent = new Intent(view.getContext(), AdvanceToGame.class);
                startActivity(myIntent);
                quitProcess();
            }

        });
        
        Button chooseColorOfPieces = (Button) findViewById(R.id.chooseColorOfPiecesButton);
        chooseColorOfPieces.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent myIntent = new Intent(view.getContext(), ChooseColorOfPiecesActivity.class);
                startActivity(myIntent);
                quitProcess();
            }

        });
        
        Button didYouKnowButton = (Button) findViewById(R.id.didYouKnowButton);
        didYouKnowButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent myIntent = new Intent(view.getContext(), DidYouKnowFirstSlide.class);
                startActivity(myIntent);
                quitProcess();
            }

        });
        
        Button goBackToMenu = (Button) findViewById(R.id.goBackToMenuButton);
        goBackToMenu.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent myIntent = new Intent(view.getContext(), WelcomeActivity.class);
                startActivity(myIntent);
                quitProcess();
            }
        });
    }
    
    @Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if ((keyCode == KeyEvent.KEYCODE_BACK)) {
			Intent myIntent = new Intent(NewGameActivity.this,
					WelcomeActivity.class);
			NewGameActivity.this.startActivity(myIntent);
			quitProcess();
		}

		return super.onKeyDown(keyCode, event);
	}
    
    protected void quitProcess() {
 	   super.onDestroy();
 	   android.os.Process.killProcess(android.os.Process.myPid());
 	}
}